﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;

namespace DataAccess
{
    public class CustomerData
    {
        ShoppingCardDataContext ctx;
        public CustomerData()
        {
            ctx = new ShoppingCardDataContext();
        }
        public bool AddNewCustomer(Customer cus)
        {
            ctx.Customers.InsertOnSubmit(cus);
            ctx.SubmitChanges();
            return true;
        }

        public Customer getCustomer()
        {
            Customer cus = (from c in ctx.Customers
                           orderby c.CustomerID descending
                           select c).First();
            return cus;
        }

        public void AddOrder()
        {

            ctx.SubmitChanges();
        }

        public void AddNewOrder(Order or)
        {
            ctx.Orders.InsertOnSubmit(or);
            ctx.SubmitChanges();
        }

        public void AddNewOrderDetail(OrderDetail orderDetail)
        {
            ctx.OrderDetails.InsertOnSubmit(orderDetail);
            ctx.SubmitChanges();
        }


    }
}
